/**
 * @file json.cpp
 * @author zeeland
 * @brief link : http://www.taichi-maker.com/homepage/esp8266-nodemcu-iot/iot-c/esp8266-nodemcu-web-client/esp8266-client-request-json/
 * it is a simple example to analysis json data
 * there is a online parser link:https://arduinojson.org/v6/assistant/
 * @version 0.1
 * @date 2022-04-17
 * 
 * @copyright Copyright (c) 2022
 * 
 */
#include <Arduino.h>
#include <ArduinoJson.h>
 
void setup() {
  Serial.begin(115200);
  Serial.println("start to work");
 
  // 重点1：DynamicJsonDocument对象
  DynamicJsonDocument doc(1024);
 
  // 重点2：即将解析的json文件
  String json = "{\"name\":\"taichi-maker\",\"number\":1}";
  
  // 重点3：反序列化数据
  deserializeJson(doc, json);
 
  // 重点4：获取解析后的数据信息
  String nameStr = doc["name"].as<String>();
  int numberInt = doc["number"].as<int>();
 
  // 通过串口监视器输出解析后的数据信息
  Serial.print("nameStr = ");Serial.println(nameStr);
  Serial.print("numberInt = ");Serial.println(numberInt);
}
 
void loop() {}